package ls.ch03.demo.demo9;

import net.sf.cglib.proxy.MethodInterceptor;
import net.sf.cglib.proxy.MethodProxy;
import org.apache.log4j.Logger;

import java.lang.reflect.Method;

/**
 * @author ls
 * @Date 创建时间:2022/4/9 14:25
 * 描述:
 */

public class IntermediaryMethodInterceptor implements MethodInterceptor {
    private Logger logger=Logger.getLogger(IntermediaryMethodInterceptor.class);
    @Override
    public Object intercept(Object proxy, Method method, Object[] args, MethodProxy methodProxy) throws Throwable {
        before();
        //调用父类原始的方法
        Object feedback=methodProxy.invokeSuper(proxy,args);
        after();
        return "看房记录：买家反馈“"+feedback+"”";
    }
    private void after() {
        System.out.println("前期准备。");
        System.out.println("查找放源。");
        System.out.println("和卖家沟通时间。");
    }

    private void before() {
        System.out.println("后期跟踪");
        System.out.println("和买家沟通意见。");
    }
}
